<?php

use Jialeo\LaravelSchemaExtend\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

class CreateUserFollowCache extends Migration
{

    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('user_follow_cache_hour',function (Blueprint $table){
            $table->comment = '埋点缓存表-根据小时';
            $table->increments('id');
            $table->date('date')->comment('日期');
            $table->unsignedInteger('hour')->comment('小时');
            $table->char('channel', 6)->default('0')->comment('渠道');
            $table->text('type_total')->default('')->comment('此小时已计算的数据');
            $table->index('date', 'date');
            $table->index('channel', 'channel');
        });

        Schema::create('user_follow_cache_day',function (Blueprint $table){
            $table->comment = '埋点缓存表-根据天';
            $table->increments('id');
            $table->date('date')->comment('日期');
            $table->char('channel', 6)->default('0')->comment('渠道');
            $table->text('type_total')->default('')->comment('此小时已计算的数据');
            $table->index('date', 'date');
            $table->index('channel', 'channel');
        });

        Schema::table('user_follows',function (Blueprint $table){
            $table->string('finger_print')->default('')->comment('h5唯一标识');
        });

        Schema::table('user_bank_cards',function (Blueprint $table){
            $table->dropIndex('card_num_is_valid');
        });

        Schema::table('user_bank_cards',function (Blueprint $table){
            $table->index('card_num', 'card_num');
        });

        Schema::table('user_bank_cards',function (Blueprint $table){
            $table->index('is_credit', 'is_credit');
        });

    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('user_follow_cache_hour');
        Schema::dropIfExists('user_follow_cache_day');
        Schema::table('user_follows',function (Blueprint $table){
            $table->dropColumn('finger_print');
        });
    }
}
